<template>
  <div class="login-container">
    <div class="bg-circle">
      <img
        class="lt"
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u3.png"
        alt=""
      />
      <img
        class="lb"
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u5.png"
        alt=""
      />
      <img
        class="rt"
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u4.png"
        alt=""
      />
    </div>
    <div class="main">
      <img
        src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u25.png"
        alt=""
      />
      <el-card shadow="never">
        <div class="title">
          <img
            src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u24.png"
            alt=""
          />
          <h2>人力资源后台管理</h2>
        </div>

        <!--登录表单-->
        <el-form :model="loginForm" :rules="loginRules" ref="loginRef">
          <el-form-item prop="mobile">
            <el-input placeholder="请输入手机号" v-model="loginForm.mobile">
              <template #prefix>
                <img
                  src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u13.png"
                  alt=""
                />
              </template>
            </el-input>
          </el-form-item>

          <el-form-item prop="password">
            <el-input placeholder="请输入密码" v-model="loginForm.password">
              <template #prefix>
                <img
                  src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u17.png"
                  alt=""
                />
              </template>
            </el-input>
          </el-form-item>

          <el-form-item prop="yanzhengma">
            <el-input placeholder="请输入验证码" v-model="loginForm.yanzhengma">
              <template #prefix>
                <img
                  src="https://img.axureshop.com/7a/4a/a8/7a4aa826e79b40d086fba67fb100e0f9/images/0登陆页/u21.png"
                  alt=""
                />
              </template>
              <template #append>
                <span>9 5 2 8</span>
              </template>
            </el-input>
          </el-form-item>

          <el-form-item prop="isAgree">
            <el-checkbox v-model="loginForm.isAgree"
              >用户平台使用协议</el-checkbox
            >
          </el-form-item>
          <el-form-item>
            <el-button type="primary" class="login-btn" @click="login" :plain="true">登录</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>
</template>
<script>
export default {
  name: "Login",
  data() {
    return {
      // 表单数据对象
      loginForm: {
        mobile: "",
        password: "",
        yanzhengma: "",
        isAgree: false,
      },
      loginRules: {
        mobile: [
          { required: true, message: "请输入手机号", trigger: "blur" },
          {
            pattern: /^1[3-9]\d{9}$/,
            message: "请输入正确手机号",
            trigger: "blur",
          },
        ],
        password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          {
            min: 6,
            max: 16,
            message: "密码长度应该为6-16位之间",
            trigger: "blur",
          },
        ],
        yanzhengma:[
          {
            required:true,message:'请输入验证码',trigger:'blur'
          },
          {
            pattern:/^9528$/,
            message:'请输入正确验证码',
            trigger:'blur'
          }
        ],
        isAgree:[
          {
            validator:(rule,value,callback) => {
              if(value) {
                callback()
              }else{
                callback(new Error("请勾选用户平台使用协议"))
              }
            },
            trigger:'change'
          }
        ]
      },
    };
  },
  methods:{
    login() {
      // 兜底校验
      this.$refs.loginRef.validate((isOK) => {
        if(isOK) {
          this.$message({
          message: '恭喜你，登录成功',
          type: 'success'
        })
        }else {
          this.$message.error('错了哦，登录失败');
        }
      })
    }
  }
};
</script>

<style lang="scss">
html,
body {
  height: 100%;
  width: 100%;
}
.login-container {
  position: relative;
  height: 100%;
  background-image: linear-gradient(#3fccfd, #996cfb);
  overflow: hidden;

  // 三个圆形图片的位置
  .bg-circle {
    .lt {
      position: absolute;
      left: 40px;
      top: 40px;
      opacity: 0.3;
    }
    .lb {
      position: absolute;
      left: -250px;
      bottom: -200px;
    }
    .rt {
      position: absolute;
      right: -70px;
      top: -200px;
    }
  }

  // 主体内容
  .main {
    // 水平和垂直居中
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;

    // 登录卡片
    .el-card {
      margin-left: 60px;

      // 卡片标题
      .title {
        display: flex;
        justify-content: center;
        align-items: center;

        font-size: 23px;
        font-weight: 700;
        font-style: normal;
        color: rgb(67, 141, 238);

        img {
          width: 50px;
          height: 42px;
        }
      }

      // 登录表单文本框
      .el-input {
        width: 350px;
        height: 44px;

        // 文本框内容
        ::v-deep .el-input__inner {
          background-color: #f4f5fb;
          height: 44px;
        }

        // 文本框头部图标样式
        img {
          width: 20px;
          height: 20px;
          margin-top: 12px;
        }

        // 文本框尾部验证码样式
        ::v-deep .el-input-group__append {
          font-family: "Arial Negreta", "Arial Normal", "Arial";
          font-weight: 700;
          font-size: 16px;
          color: #ff7733;
          // height: 44px;
        }
      }

      // 复选款样式
      .el-checkbox {
        color: #606266;
      }

      // 登录按钮样式
      .login-btn {
        width: 350px;
      }
    }
  }
}
</style>